Component({
    properties: {},
    data: {
        time:{
            currentYMD: '',
            currentWeek:'',
        },
    },
    methods: {
        getTime(){
            const date = new Date();
            const currentYMD = `${date.getFullYear()} 年 ${date.getMonth() + 1} 月 ${date.getDate()} 日`;
            const currentWeek = `星期${'日一二三四五六'.charAt(date.getDay())}`;

            this.setData({
                'time.currentYMD': currentYMD,
                'time.currentWeek': currentWeek,
            });
        },

    },
    lifetimes: {
        attached() {
            this.getTime();
            setInterval(() => {
                this.getTime();
                // this.getPositionByIP();
            }, 1000);
        },
        detached() {
            // 在组件实例被从页面节点树移除时执行
            clearInterval(this.data.timer);
        }
    }
});
